<template>
  <div id="userSitting">
    <div class="userBox">
      <div class="userImg">
        <h3>头像</h3>
        <img
          src="https://tsyx-rights-and-interests.oss-cn-hangzhou.aliyuncs.com/icon/petroleum.png"
          alt=""
          class="userBoxCss"
        />
      </div>
      <div class="userImg">
        <h3>昵称</h3>
        <p class="userBoxCss">{{ user.nickName }}</p>
      </div>
      <div class="userImg">
        <h3>手机号</h3>
        <p class="userBoxCss">{{ user.phoneNumber }}</p>
      </div>
      <div class="userImg">
        <h3>身份证号</h3>
        <p class="userBoxCss">{{ user.cardNumber }}</p>
      </div>
      <div class="userImg">
        <h3>行驶证VIN</h3>
        <p class="userBoxCss">{{ user.carVin }}</p>
      </div>
    </div>
    <div class="checkUser" @click="overUser">切换账号</div>
  </div>
</template>

<script>
import { Dialog, Toast } from "vant";
export default {
  data() {
    return {
      user: {},
    };
  },
  created() {
    this.user = JSON.parse(window.localStorage.getItem("userMsg"));
  },
  methods: {
    overUser() {
      Dialog.confirm({
        title: "切换账号",
        message: "您确定注销此账号，重新登陆其他账号吗？",
      })
        .then(() => {
          // on confirm
          window.localStorage.setItem("userMsg", JSON.stringify({}));
          window.localStorage.setItem("logintoken", "");
          window.localStorage.setItem("phone", "");
          this.$store.state.isright = false;
          this.$router.push({
            name: "getUser",
            query: {
              spid: "my",
            },
          });
        })
        .catch(() => {
          // on cancel
        });
    },
  },
};
</script>

<style lang='scss' scoped>
#userSitting {
  padding-top: 1rem;
  padding-bottom: 5rem;
}
.userBox {
  width: 90%;
  margin: auto;
  box-shadow: 0px 10px 35px 0px rgba(198, 198, 198, 0.36);
  .userImg {
    position: relative;
    background-color: #fff;
    height: 1.5rem;
    h3 {
      font-weight: 400;
      font-size: 0.45rem;
      line-height: 1.5rem;
      padding-left: 0.5rem;
      margin: 0;
    }
    .userBoxCss {
      position: absolute;
      top: 50%;
      right: 0.5rem;
      transform: translateY(-50%);
    }
    img {
      width: 15%;
    }
    p {
      color: #999;
      margin: 0;
      font-size: 0.4rem;
    }
  }
}
.checkUser {
  width: 90%;
  padding: 0.5rem 0;
  text-align: center;
  background-color: #fff;
  margin: 1rem auto;
  border-radius: 0.15rem;
  font-size: 0.4rem;
  box-shadow: 0px 10px 35px 0px rgba(198, 198, 198, 0.36);
}
</style>